import { http } from "@/utils/http";
import { baseAdminURLApi } from "../utils";
export type SiteResult = {
  url: string;
};

/** 获取网站config */
export const getSiteInfo = () => {
  return http.request<SiteResult>("get", baseAdminURLApi("/siteInfo"), {});
};

/** 获取gitee代码提交记录 */
export const getCommitList = () => {
  return http.request<Array<object>>(
    "get",
    "/gitee/contribution_timeline?url=%2Fmrzym%2Fcontribution_timeline&scope=my&day=&start_date=&end_date=&year=&limit=180&prev_id=&_=1683426798995"
  );
};

/** 修改网站config */
export const updateSiteInfo = data => {
  return http.request("put", baseAdminURLApi("/siteInfo"), {
    data
  });
};

/** 图片上传接口 */
export const ImgUpload = async (file: File): Promise<SiteResult> => {
  return http.upload<SiteResult>(baseAdminURLApi("/file/upload/img"), file);
};

/** 更新简历 */
export const updateIntroduction = (data: string) => {
  return http.request("put", baseAdminURLApi("/siteInfo/introduction"), {
    data,
    headers: {
      "Content-Type": "text/plain"
    }
  });
};

/** 修改头像 */
export const uploadAvatar = (file?: File) => {
  return http.upload(baseAdminURLApi("/siteInfo/avatar"), file, "avatar");
};

/** 修改背景图 */
export const uploadBgImage = (file?: File) => {
  return http.upload(baseAdminURLApi(`/siteInfo/bgImage`), file, "bgImage");
};
